function ret = Knee2D_pos(xpos,Lc,Lt,StartPt,EndPt,angle,...
    StanceLegIndex)

if StanceLegIndex == 1 % right leg is the stance leg
    
    % hip position, calculated directly from human position data
    HipPos = HipPosition(xpos.lhip);
else
    HipPos = HipPosition(xpos.rhip);
end
% for i = 1:(EndPt-StartPt+1)
    HipPosL =  LinearizedHipPosition(Lc,Lt,angle);
% end
ret.hip_pos = HipPos(StartPt:EndPt);
ret.hip_pos_Linearized = HipPosL;

end

% unshifted hip position
function ret = HipPosition(xhip)
ret = xhip'; % hip position along the whole steps
end

% unshifted linearized hip position
function ret = LinearizedHipPosition(Lc, Lt, angle)
ret  = -Lc.*angle.sa - Lt.*(angle.sa+angle.sknee);
end

